package org;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.kms.dao.*;
import org.kms.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.net.Inet4Address;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class text {
    @Autowired
    private org.kms.dao.recruitDao recruitDao;
@Autowired
private kmsPermissionDao kmsPermissionDao;
@Autowired
private kmsRoleDao kmsRoleDao;

@Autowired
private kqinfoDao kqinfoDao;

@Autowired
private fxinfoDao fxinfoDao;

@Autowired
private childDao childDao;

@Autowired
private selectedchargesDao selectedchargesDao;


@Test
public void aa(){

    List<Selectedcharges> a = selectedchargesDao.getbytime("2018-12-01","2018-12-31",10);
    Integer [] inta = new Integer[a.size()];
    for (int j = 0; j < inta.length; j++) {
             for (int i = 0; i < a.get(j).getChilds().size(); i++) {
                  inta[j] = a.get(j).getChilds().get(i).getPid();
             }

    }
    for (int s = 0; s <inta.length ; s++) {
        List<Selectedcharges> selectedchargesList = selectedchargesDao.getbyPid("2018-12-01","2018-12-31",inta[s]);
        List<Fxinfo> fxinfos = new ArrayList<Fxinfo>();
        for (Selectedcharges t: selectedchargesList
        ) {
            for (Fxinfo p:t.getFxinfos()
            ) {
              Fxinfo fxinfo = new Fxinfo();
                fxinfo.setCharge(p.getCharge());
                fxinfo.setcIid(p.getcIid());
                fxinfo.setCiName(p.getCiName());
                fxinfo.setCiTime(p.getCiTime());
                fxinfo.setCompany(p.getCompany());
               fxinfo.setTypesid(p.getTypesid());
               fxinfo.setGlId(p.getGlId());
               fxinfo.setPrice(p.getPrice());

            }
        }
        a.get(s).setFxinfos(fxinfos);
    }
}







/*@Test
public void aa (){
    childDao.getbytime();
}*/

@Test
public void p(){
    List<Integer> a = fxinfoDao.getbynotclid(8);
    for (int i = 0; i < a.size(); i++) {
        System.out.println(a.get(i));
    }
}
@Test
public void o(){
    Kqinfomanager kqinfomanager = new Kqinfomanager();

    /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String d = sdf.format(new Date());
    System.out.println(new Date());*/
    kqinfomanager.setGlId(2);
    kqinfomanager.setSign("2018-12-24");
    kqinfomanager.setB("2018-12-26");
    Child child = new Child();
    child.setGradeId(4);
    child.setCmId(11);
   /* kqinfomanager.setChild(child);*/
    List<Kqinfomanager> kqinfomanagers =kqinfoDao.getConditionList(kqinfomanager);
    for (Kqinfomanager k:kqinfomanagers
         ) {
        System.out.println(k.getaMid());
    }
}
@Test
public void list(){
    List<KmsPermission> one =kmsPermissionDao.getfirstmenu();
    for (KmsPermission first:one
         ) {
        System.out.println(first.getName());
        for (KmsPermission second:first.getChildren()
             ) {
            System.out.println(second.getName());
            for (KmsPermission third:second.getChildren()
                 ) {
                System.out.println(third.getName());
            }
        }
    }
}

@Test
public void a(){
    Recruit rec = new  Recruit();
    rec.setcName("");
    List<Recruit> recruit = recruitDao.getConditionList(rec);
    for (Recruit  r:
            recruit) {
        System.out.println(r.getcName());
    }
}
@Test
public void c(){
    List<KmsPermission> geta = kmsPermissionDao.getbyerji(1);
    for (KmsPermission a:geta
         ) {
        System.out.println(a.getPerName());
    }
}

    @Test
    public void t(){
        List<Integer> geta = kmsPermissionDao.getbythreeperida(128);
        for (Integer a:geta
        ) {
            System.out.println(a);
        }
    }
    @InitBinder
    public void InitBinder(WebDataBinder webDataBinder) throws Exception{
        //日期类型转换器
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        CustomDateEditor dateEditor = new CustomDateEditor(simpleDateFormat,true);
        //注册类型换换器:如果碰到Date.class 都会转成yyyy-MM-dd格式
        webDataBinder.registerCustomEditor(Date.class,dateEditor);
    }

}
